import java.util.*;

class Student implements Comparable<Student> {
    String name;
    int year;
    int month;
    int day;
    String studentId;
    String school;

    public Student(String name, int year, int month, int day, String studentId, String school) {
        this.name = name;
        this.year = year;
        this.month = month;
        this.day = day;
        this.studentId = studentId;
        this.school = school;
    }

    public int compareTo(Student o){
        return this.studentId.compareTo(o.studentId);
    }

    public String toString(){
        return String.format("Student[name=%s, birthday=%d-%02d-%02d, studentId=%s, school=%s]",name,year,month,day,studentId,school);
    }
}

public class Main7{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int num=in.nextInt();
        Student[] studentArray = new Student[num];
        for(int i=0;i<num;i++)
        {
            String name=in.next();
            int year=in.nextInt();
            int month=in.nextInt();
            int day=in.nextInt();
            String studentId=in.next();
            String school=in.next();
            studentArray[i]=new Student(name,year,month,day,studentId,school);
        }

        Arrays.sort(studentArray);
        for(Student s:studentArray)
            System.out.println(s);
    }
}
